import type { NodeProps, Node } from "@xyflow/react"

export interface DBTable {
  id: string
  name: string
  schema?: string
  x: number
  y: number
  fields: DBField[]
  indexes: DBIndex[]
  color: string
  isView: boolean
  isMaterializedView?: boolean
  createdAt: number
  width?: number
  comments?: string
  order?: number
}

export interface DBField {
  id: string
  name: string
  type: DataType
  primaryKey: boolean
  unique: boolean
  nullable: boolean
  createdAt: number
  characterMaximumLength?: string
  precision?: number
  scale?: number
  default?: string
  collation?: string
  comments?: string
}
export interface DBIndex {
  id: string
  name: string
  unique: boolean
  fieldIds: string[]
  createdAt: number
}
export interface DataType {
  id: string
  name: string
}

export type TableNodeType = Node<
  {
    table: DBTable
    isOverlapping: boolean
    highlightOverlappingTables?: boolean
  },
  "table"
>
